#include "Base.h"
#include "GameProtocol.h"


BOOL CSEnterMatch::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_dwProductId, sizeof(m_dwProductId));
	iStream.Read((char*)&m_dwMatchId, sizeof(m_dwMatchId));
	iStream.Read((char*)&m_dwUserId, sizeof(m_dwUserId));
	iStream.Read((char*)&m_nStartType, sizeof(m_nStartType));
	iStream.Read((char*)&m_dwWatchUserId, sizeof(m_dwWatchUserId));
	iStream.Read((char*)&m_nEncryptParamLen, sizeof(m_nEncryptParamLen));
	iStream.Read((char*)&m_byEncryptParam, sizeof(m_byEncryptParam));
	return TRUE;
}

BOOL CSEnterMatch::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_dwProductId, sizeof(m_dwProductId));
	oStream.Write((char*)&m_dwMatchId, sizeof(m_dwMatchId));
	oStream.Write((char*)&m_dwUserId, sizeof(m_dwUserId));
	oStream.Write((char*)&m_nStartType, sizeof(m_nStartType));
	oStream.Write((char*)&m_dwWatchUserId, sizeof(m_dwWatchUserId));
	oStream.Write((char*)&m_nEncryptParamLen, sizeof(m_nEncryptParamLen));
	oStream.Write((char*)&m_byEncryptParam, sizeof(m_byEncryptParam));
	return TRUE;
}

BOOL SCEnterMatchMsg::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_dwUserId, sizeof(m_dwUserId));
	iStream.Read((char*)&m_szUserName, sizeof(m_szUserName));
	iStream.Read((char*)&m_nStartType, sizeof(m_nStartType));
	iStream.Read((char*)&m_nResult, sizeof(m_nResult));
	return TRUE;
}

BOOL SCEnterMatchMsg::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_dwUserId, sizeof(m_dwUserId));
	oStream.Write((char*)&m_szUserName, sizeof(m_szUserName));
	oStream.Write((char*)&m_nStartType, sizeof(m_nStartType));
	oStream.Write((char*)&m_nResult, sizeof(m_nResult));
	return TRUE;
}

BOOL SCEnterGame::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_nSeat, sizeof(m_nSeat));
	iStream.Read((char*)&m_dwUserId, sizeof(m_dwUserId));
	iStream.Read((char*)&m_szUserName, sizeof(m_szUserName));
	iStream.Read((char*)&m_nFigure, sizeof(m_nFigure));
	iStream.Read((char*)&m_nStartType, sizeof(m_nStartType));
	iStream.Read((char*)&m_nScore, sizeof(m_nScore));
	m_GameAttrs.Read(iStream);
	return TRUE;
}

BOOL SCEnterGame::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_nSeat, sizeof(m_nSeat));
	oStream.Write((char*)&m_dwUserId, sizeof(m_dwUserId));
	oStream.Write((char*)&m_szUserName, sizeof(m_szUserName));
	oStream.Write((char*)&m_nFigure, sizeof(m_nFigure));
	oStream.Write((char*)&m_nStartType, sizeof(m_nStartType));
	oStream.Write((char*)&m_nScore, sizeof(m_nScore));
	m_GameAttrs.Write(oStream);
	return TRUE;
}

BOOL CSStartGame::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_nSeat, sizeof(m_nSeat));
	return TRUE;
}

BOOL CSStartGame::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_nSeat, sizeof(m_nSeat));
	return TRUE;
}

BOOL SCStartGame::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_nCurHand, sizeof(m_nCurHand));
	iStream.Read((char*)&m_nScoreBase, sizeof(m_nScoreBase));
	iStream.Read((char*)m_szGameRuler, sizeof(m_szGameRuler));
	return TRUE;
}

BOOL SCStartGame::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_nCurHand, sizeof(m_nCurHand));
	oStream.Write((char*)&m_nScoreBase, sizeof(m_nScoreBase));
	oStream.Write((char*)m_szGameRuler, sizeof(m_szGameRuler));
	return TRUE;
}

BOOL SCGameOver::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_nCurHand, sizeof(m_nCurHand));
	return TRUE;
}

BOOL SCGameOver::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_nCurHand, sizeof(m_nCurHand));
	return TRUE;
}

BOOL SCPlayerBreak::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_nSeat, sizeof(m_nSeat));
	return TRUE;
}

BOOL SCPlayerBreak::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_nSeat, sizeof(m_nSeat));
	return TRUE;
}

BOOL SCMatchInfoMsg::Read( CSocketStream& iStream )
{
	int nCount = 0;
	iStream.Read((char*)&nCount, sizeof(nCount));
	for(int i = 0; i < nCount; i++)
	{
		MatchAttr attr = {0};
		iStream.Read((char*)&attr, sizeof(attr));
		m_listMatchAttr.AddTail(attr);
	}
	return TRUE;
}

BOOL SCMatchInfoMsg::Write( CSocketStream& oStream ) const
{
	int nCount = m_listMatchAttr.GetCount();
	oStream.Write((char*)&nCount, sizeof(nCount));
	for(int i = 0; i < nCount; i++)
	{
		MatchAttr &attr = m_listMatchAttr.GetAt(i);
		oStream.Write((char*)&attr, sizeof(attr));
	}
	return TRUE;
}

BOOL SCUserOrderMsg::Read( CSocketStream& iStream )
{
	int nCount = 0;
	iStream.Read((char*)&nCount, sizeof(nCount));
	for(int i = 0; i < nCount; i++)
	{
		UserOrder userOrder;
		iStream.Read((char*)&userOrder, sizeof(userOrder));
		m_listUserOrder.AddTail(userOrder);
	}
	return TRUE;
}

BOOL SCUserOrderMsg::Write( CSocketStream& oStream ) const
{
	int nCount = m_listUserOrder.GetCount();
	oStream.Write((char*)&nCount, sizeof(nCount));
	for(int i = 0; i < nCount; i++)
	{
		UserOrder &userOrder = m_listUserOrder.GetAt(i);
		oStream.Write((char*)&userOrder, sizeof(userOrder));
	}
	return TRUE;
}

BOOL SCTipTextMsg::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_szTip, sizeof(m_szTip));
	return TRUE;
}

BOOL SCTipTextMsg::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_szTip, sizeof(m_szTip));
	return TRUE;
}

BOOL SCMatchAwardMsg::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_dwUserId, sizeof(m_dwUserId));
	m_stOrderAward.Read(iStream);
	return TRUE;
}

BOOL SCMatchAwardMsg::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_dwUserId, sizeof(m_dwUserId));
	m_stOrderAward.Write(oStream);
	return TRUE;
}

BOOL SBCallBotUserMsg::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_dwProductId, sizeof(m_dwProductId));
	iStream.Read((char*)&m_dwMatchId, sizeof(m_dwMatchId));
	iStream.Read((char*)&m_dwUserId, sizeof(m_dwUserId));
	return TRUE;
}

BOOL SBCallBotUserMsg::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_dwProductId, sizeof(m_dwProductId));
	oStream.Write((char*)&m_dwMatchId, sizeof(m_dwMatchId));
	oStream.Write((char*)&m_dwUserId, sizeof(m_dwUserId));
	return TRUE;
}

BOOL CSTrustPlay::Read(CSocketStream& iStream)
{
	iStream.Read((char*)&m_bTrustPlay, sizeof(m_bTrustPlay));
	return TRUE;
}

BOOL CSTrustPlay::Write(CSocketStream& oStream) const
{
	oStream.Write((char*)&m_bTrustPlay, sizeof(m_bTrustPlay));
	return TRUE;
}
